package com.briup.ch04;

import java.util.Arrays;

public class Test4 {
    public static void reverseArray(int[] arr)
    {
        int len=arr.length;
        for(int i=0;i<len/2;i++)
        {
            arr[i]=arr[i]^arr[len-1-i];
            arr[len-1-i]=arr[i]^arr[len-1-i];//arr[len-1-i]=arr[i]^arr[len-1-i]^arr[len-1-i]=arr[i]^0=arr[i];
            arr[i]=arr[i]^arr[len-1-i];//arr[i]=arr[i]^arr[len-1-i]^arr[i]=0^arr[len-1-i]=arr[len-1-i];
        }
    }

    public static void main(String[] args) {
        int[] arr={1,3,5,2,6,8};
        System.out.println(Arrays.toString(arr));
        reverseArray(arr);
        System.out.println(Arrays.toString(arr));
    }
}
